package top.lyjwn.todo.aop.log.controller;

public enum ControllerOperat {
	SAVE("save", "保存"), SELETE("find", "查询"), DELETE("delete", "删除"), LOGIN("login", "登录"), REGISTER("register", "注册");

	String type;

	String name;

	ControllerOperat(String type) {
		switch (type) {
		case "save":
			this.name = "保存";
			break;
		case "find":
			this.name = "查询";
			break;
		case "delete":
			this.name = "删除";
			break;
		case "login":
			this.name = "登录";
			break;
		case "register":
			this.name = "注册";
			break;
		}
		this.type = type;
	}

	private ControllerOperat(String type, String name) {
		this.type = type;
		this.name = name;
	}

	public static ControllerOperat from(String type) {
		for (ControllerOperat operat : ControllerOperat.values()) {
			if (operat.type.equals(type)) {
				return operat;
			}
		}
		return null;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	static boolean IsDefined(String type) {
		boolean bl = false;
		for (int i = 0; i < ControllerOperat.values().length; i++) {
			bl |= ControllerOperat.values()[i].type.equals(type);
		}
		return bl;
	}
}
